// 案件状态枚举
export enum CaseStatus {
  OPEN = 'OPEN',            // 已开启
  IN_PROGRESS = 'IN_PROGRESS',  // 进行中
  CLOSED = 'CLOSED'         // 已关闭
}

// 案件实体类
export class CaseModel {
  private id: string;        // 案件ID
  private title: string;     // 案件标题
  private description: string; // 案件描述
  private status: CaseStatus; // 案件状态
  private createTime: string; // 创建时间
  private updateTime: string; // 更新时间
  private createBy: string;  // 创建人ID
  
  constructor(
    id: string = '',
    title: string = '',
    description: string = '',
    status: CaseStatus = CaseStatus.OPEN,
    createTime: string = new Date().toISOString(),
    updateTime: string = new Date().toISOString(),
    createBy: string = ''
  ) {
    this.id = id;
    this.title = title;
    this.description = description;
    this.status = status;
    this.createTime = createTime;
    this.updateTime = updateTime;
    this.createBy = createBy;
  }
  
  // Getters
  public getId(): string {
    return this.id;
  }
  
  public getTitle(): string {
    return this.title;
  }
  
  public getDescription(): string {
    return this.description;
  }
  
  public getStatus(): CaseStatus {
    return this.status;
  }
  
  public getCreateTime(): string {
    return this.createTime;
  }
  
  public getUpdateTime(): string {
    return this.updateTime;
  }
  
  public getCreateBy(): string {
    return this.createBy;
  }
  
  // Setters
  public setId(id: string): void {
    this.id = id;
  }
  
  public setTitle(title: string): void {
    this.title = title;
  }
  
  public setDescription(description: string): void {
    this.description = description;
  }
  
  public setStatus(status: CaseStatus): void {
    this.status = status;
    this.updateTime = new Date().toISOString();
  }
  
  public setCreateBy(createBy: string): void {
    this.createBy = createBy;
  }
  
  /**
   * 从JSON对象创建CaseModel实例
   * @param json JSON对象
   * @returns CaseModel实例
   */
  public static fromJson(json: any): CaseModel {
    return new CaseModel(
      json.id || '',
      json.title || '',
      json.description || '',
      json.status || CaseStatus.OPEN,
      json.createTime || new Date().toISOString(),
      json.updateTime || new Date().toISOString(),
      json.createBy || ''
    );
  }
  
  /**
   * 转换为JSON对象
   * @returns JSON对象
   */
  public toJson(): any {
    return {
      id: this.id,
      title: this.title,
      description: this.description,
      status: this.status,
      createTime: this.createTime,
      updateTime: this.updateTime,
      createBy: this.createBy
    };
  }
  
  /**
   * 生成唯一ID
   * @returns 唯一ID字符串
   */
  public static generateId(): string {
    return Date.now().toString() + Math.random().toString(36).substr(2, 9);
  }
}